/*Cookie */
var Cookie ={
    get:function(_name){
        var arr,
            reg = new RegExp("(^| )" + _name + "=([^;]*)(;|$)");
        if(arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
        /*var cookies = document.cookie, pos = cookies.indexOf(_name+'='), value;//这样是包含关系，查找的时候可能查找到多个
         if(pos !== -1){
         var start = pos + _name.length+1;
         var end = cookies.indexOf(';',start);
         //最后一个
         if(end === -1){end = cookies.length;}
         value = cookies.substring(start,end);
         value = decodeURIComponent(value);
         }
         return value;*/
    },
    set:function(_name,_value,minutes){
        if(minutes){
            var expi = new Date();
            expi.setMinutes(minutes);
            document.cookie = _name+'='+encodeURIComponent(_value)+';expires='+expi.toGMTString();
        }else{
            document.cookie = _name+'='+encodeURIComponent(_value);
        }
    },
    clearcookie:function(_name,_path,_domain){
        if(cookie.get(_name)) {
            document.cookie= _name+'='+ ((_path)?';path='+_path:'') + ((_domain)?';domain='+_domain:'') + ';expires=Thu,01-Jan-1970 00:00:01 GMT';
        }
    }
}
export default Cookie